'use strict';

module.exports = {
  up: async (queryInterface, Sequelize) => {
    /**
     * Add altering commands here.
     *
     * Example:
     * await queryInterface.createTable('users', { id: Sequelize.INTEGER });
     */
    const { INTEGER, STRING, DATE } = Sequelize;
    await queryInterface.createTable("sys_user", {
      user_id: {
        type: INTEGER(20),
        comment: "用户ID",
        allowNull:false,
        primaryKey: true,
        autoIncrement: true
      },
      dept_id:{
        type:INTEGER(20),
        comment:"部门ID",
      },
      user_name:{
        type:STRING(30),
        comment:"登录账号",
        allowNull:false
      },
      nick_name:{
        type:STRING(30),
        comment:"用户昵称",
        defaultValue:""
      },
      user_type:{
        type:STRING(2),
        comment:"用户类型",
        defaultValue:"00"
      },
      email:{
        type:STRING(50),
        comment:"用户邮箱",
        defaultValue:""
      },
      phonenumber:{
        type:STRING(11),
        comment:"手机号码",
        defaultValue:""
      },
      sex:{
        type:STRING(1),
        comment:"用户性别（0男 1女 2未知）",
        defaultValue:""
      },
      avatar:{
        type:STRING(100),
        comment:"头像路径",
        defaultValue:""
      },
      password:{
        type:STRING(100),
        comment:"密码",
        defaultValue:""
      },
      status:{
        type:STRING(1),
        comment:"帐号状态（0正常 1停用）",
        defaultValue:"0"
      },
      login_ip:{
        type:STRING(128),
        comment:"最后登录IP",
        defaultValue:""
      },
      login_date:{
        type:DATE,
        comment:"最后登录时间",
        // defaultValue: Sequelize.NOW
      },
      create_by:{
        type:STRING(64),
        comment:"创建者",
      },
      update_by:{
        type:STRING(64),
        update_by:"更新者"
      },
      remark:{
        type:STRING(500),
        defaultValue:"",
        comment:"备注"
      },
      created_at:{
        type:DATE,
        comment:"创建时间",
      },
      updated_at:{
        type:DATE,
        comment:"更新时间",
      },
      deleted_at:{
        type:DATE,
        comment:"删除时间",
      }
    })
  },

  down: async (queryInterface, Sequelize) => {
    /**
     * Add reverting commands here.
     *
     * Example:
     * await queryInterface.dropTable('users');
     */
     await queryInterface.dropTable("sys_user");
  }
};
